<?php
namespace app\store\controller\food;

use app\store\controller\food\Controller;
use app\store\model\Page as PageModel;

/**
 * 页面升级
 */
class Tool extends Controller
{
    /**
     * 页面升级
     */
    public function v416()
    {
        $model = (new PageModel)->withoutGlobalScope()->column('page_id');
        foreach ($model as $vo) {
            $page = PageModel::withoutGlobalScope()->where('page_id',$vo)->find();
            if(!isset($page['page_data']['array']['tabbar'])){
                $page_data = $page['page_data']['array'];
                $page_data['tabbar'] = [
                    'type' => 'tabbar',
                    'name' => '导航设置',
                    'list' => [
                        [
                            'text' => '首页', //标题
                            'iconPath' =>  base_url().'assets/img/diy/tabbar/home.png', //选中状态图标
                            'selectedIconPath' => base_url().'assets/img/diy/tabbar/home_on.png', //激活(选中)的图标
                            'pagePath' =>'/pages/index/index', //路径需要以"/"开头
                        ],
                        [
                            'text' => '订单', //标题
                            'iconPath' =>  base_url().'assets/img/diy/tabbar/order.png', //选中状态图标
                            'selectedIconPath' => base_url().'assets/img/diy/tabbar/order_on.png', //激活(选中)的图标
                            'pagePath' =>'/pages/order/index', //路径需要以"/"开头
                            'midButton' => false, //图标凸起
                            /*
                            图标建议尺寸为80px * 80px
                            凸起图标建议为120px * 120px的png图片
                             */
                        ],
                        [
                            'text' => '我的', //标题
                            'iconPath' =>  base_url().'assets/img/diy/tabbar/user.png', //选中状态图标
                            'selectedIconPath' => base_url().'assets/img/diy/tabbar/user_on.png', //激活(选中)的图标
                            'pagePath' =>'/pages/user/index', //路径需要以"/"开头
                        ]
                    ],
                    'style' => [
                        'borderTop' => true,    //是否显示顶部的边框
                        'midButton' => false, //中间凸起
                        'activeColor' => '#000000', //激活时的颜色
                        'inactiveColor' => '#6e6d6b',   //未激活时的颜色
                        'bgColor' => '#ffffff', //背景颜色
                    ],
                    'id' => 'tabbar'
                ];
                $page->save(['page_data' => $page_data]);
            }
        }
        echo "升级成功";
    }
}
